﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HR.ProjectX.BLL.ViewModels;
using HR.ProjectX.DAL.UnitOfWork;
using HR.ProjectX.DAL.Repositories;
using HR.ProjectX.BLL.Messaging;
using HR.ProjectX.Models.Entities.Vehicles;

namespace HR.ProjectX.BLL.Services.VehicleCategoryService
{
    public class VehicleCategoryService : IVehicleCategoryService
    {
        private readonly IUnitOfWork _uow;
        private readonly IVehicleCategoryRepository _vehicleCategoryRepository;

        public VehicleCategoryService(IUnitOfWork uow,
                                      IVehicleCategoryRepository vehicleCategoryRepository)
        {
            _uow = uow;
            _vehicleCategoryRepository = vehicleCategoryRepository;
        }

        public GetAllVehicleCategoriesResponse GetAllVehicleCategories()
        {
            IList<VehicleCategory> vehicleCategories = _vehicleCategoryRepository.FindAll();
            IList<VehicleCategoryView> viewModels = new List<VehicleCategoryView>();

            // Ik doe de mapping zelf ipv Automapper.
            foreach (VehicleCategory category in vehicleCategories)
            {
                VehicleCategoryView viewModel = new VehicleCategoryView();
                viewModel.VehicleDescription = category.VehicleCategoryDescription;

                viewModels.Add(viewModel);
            }

            GetAllVehicleCategoriesResponse response = new GetAllVehicleCategoriesResponse();
            response.VehicleCategories = viewModels;

            return response;
        }
    }
}
